#属性不要和方法同名；
#property装饰器：把一个方法变成getter，@该方法名.setter，才可以设置值
class Student:
    def __init__(self,name="未输入",age=-1) -> None:
        self._name=name
        self._age=age
    
    @property
    def name(self):
        return self._name
    # @name.setter
    # def age(self,name):
    #     self._name=name
    @property
    def age(self):
        return self._age
    @age.setter
    def age(self,age):
        self._age=age
    def show_info(self):
        print(f"姓名：{self.name}，年龄：{self.age}")

def main():
    s=Student()
    s.show_info()
    s.age=20
    s.show_info()
    # s.name="张三"  #AttributeError: property 'name' of 'Student' object has no setter
if __name__=="__main__":
    main()